package com.zds.transaction.service.impl;

import com.zds.transaction.mapper.AccountMapper;
import com.zds.transaction.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @className:AccountServiceimpl
 * @date: 2025/6/16 下午4:28
 * @description:
 */
@Service
public class AccountServiceimpl implements AccountService {
    @Autowired
    private AccountMapper accountMapper;
    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,propagation = Propagation.REQUIRED,readOnly = false,timeout = 5)
    public void transferMoney(String from, String to, Integer amount) {
        accountMapper.decrMoney(from,amount);
        //int a = 1/0;
        accountMapper.incrMoney(to,amount);
    }
}
